package company.GuangLianDa;

import java.util.Arrays;
import java.util.Scanner;

/**
 * @ClassName P2
 * @Description
 * @Company inspur
 * @Author Kevin
 * @Date 2020/7/31 21:19
 * @Version 1.0
 */
public class P2 {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] data = new int[n];
        int[] nums = new int[n];

        for (int i = 0; i < n; i++) {
            data[i] = sc.nextInt();
            nums[i] = data[i];
        }
        Arrays.sort(nums);

        int counts = 0;

        for (int i = n-1, j = n-1; i >= 0; i--) {
            if (nums[j] == data[i]) {
                counts++;
                j--;
            }
        }

        System.out.println(n - counts);

        return;
    }
}
